package com.example.demo.service;

import com.example.demo.dao.ReturngoodMapper;
import com.example.demo.entity.CommonResult;
import com.example.demo.entity.Returngoods;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReturngoodService implements Returngoodimpl {

     @Autowired
    ReturngoodMapper returngoodMapper;
    @Override
    public CommonResult GetOnepagesreturngood(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Returngoods> getallregood = returngoodMapper.Getallregood();
        if (getallregood.size() <= 0) {
            return new CommonResult(200, "暂时没有退货记录");
        }
        PageInfo pageInfo = new PageInfo(getallregood);
        return new CommonResult(200, "退货记录第" + pageInfo.getPageNum() + "页获取成功", pageInfo);
    }

    @Override
    public CommonResult selectgoods(String drug_id, String sale_time) {

        List<Returngoods> selectgoods = returngoodMapper.selectgoods(drug_id, sale_time);
        return new CommonResult(200,"退货信息",selectgoods);
    }
}
